CC=gcc
CFLAGS=-Wall -pedantic -g --std=c99
LIBS=-lm
ALLOBJS=$(patsubst %.c,%.o,$(wildcard *.c))

TDISKOBJS=disk.o process.o queue.o tests/test_disk.o
TDISKINCS=disk.h process.h queue.h simulator.h

TTREADOBJS=tread.o process.o tests/test_tread.o
TTREADINCS=tread.h process.h

TSTCPOBJS=stcp.o process.o pqueue.o tests/test_stcp.o observer.o exp.o queue.o
TSTCPINCS=schedule.h process.h pqueue.h observer.h queue.h

TPROCOBJS=process.o tests/test_process.o
TPROCINCS=process.h

TQUEUESOBJS=queue.o pqueue.o process.o observer.o tests/test_queues.o
TQUEUESINCS=queue.h pqueue.h process.h observer.h simulator.h


all: $(ALLOBJS)
	$(CC) $(CFLAGS) $(LIBS) -o 537sim $(ALLOBJS)

test_disk: $(TDISKOBJS)
	$(CC) $(CFLAGS) $(LIBS) -o test_disk $(TDISKOBJS)

test_queues: $(TQUEUESOBJS)
	$(CC) $(CFLAGS) $(LIBS) -o test_queues $(TQUEUESOBJS)

test_process: $(TPROCOBJS)
	$(CC) $(CFLAGS) $(LIBS) -o test_process $(TPROCOBJS)

test_stcp: $(TSTCPOBJS)
	$(CC) $(CFLAGS) $(LIBS) -o test_stcp $(TSTCPOBJS)

test_tread: $(TTREADOBJS)
	$(CC) $(CFLAGS) $(LIBS) -o test_tread $(TTREADOBJS)

%.o: %.c %.h
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	rm -f *.o tests/*.o 537sim test_disk test_process test_stcp test_tread a.out
